import type { Directive } from "vue";

/**
 * 自动滚动指令
 */
export const autoScrollDirective: Directive = {
  updated(el: HTMLElement, binding) {
    if (!binding.arg) throw Error("请传入arg参数")

    // TODO:后续扩展
    switch (binding.arg) {
      case 'bottom':
        if (!isVerticalScrollable) throw Error('该元素不能纵向滚动 请设置style')
        el.scrollTop = el.scrollHeight
        break
      default:
        throw Error("当前该指令仅支持 bottom")
    }
  }
}

